home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
earkit
/
news
/
thor
/
rexx
/
bbsread
/
deldupes.br
< prev
next >
Wrap
Text File
|
1998-05-24
|
6KB
|
185 lines
/*
** $VER: DelDupes.br 1.5 (4.9.97)
** by Eirik Nicolai Synnes
**
** This script will delete duplicate entries in the file database. The first
** occurence of each filename will be kept, subsequent occurences IN ANY FILE
** AREA will be deleted. (currently, I'll do something about this later)
**
**
** Usage: DelDupes.br SYSTEM/M,ALL/S,USEEXCLUDES/S,PURGE/S,QUIET/S
**
** Args: SYSTEM The name of the system you want to check. Multiple
** systems can be specified
** ALL Check dupes on all systems
** USEEXCLUDE Delete file areas in SortMail's exclude file
** See SortMail.guide -> Actions Cfg -> Aminet
** PURGE Perform file database maintainance afterwards
** QUIET Don't display any progress information
**
** Example: DelDupes.br "Ygdrasil" "Ultima Thule" PURGE
**
**
** New for 1.4:
** o USEEXCLUDES command line switch
**
** New for 1.50:
** o Version numbering will from now on follow the C= guidelines
**
** Ideas:
** o GUI interface if run from Thor
** o Allow identical filenames across file areas
**
*/
options results
signal on break_c
signal on halt
trace off
parse arg arguments
/* Find BBSREAD ARexx ports' */
if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
/* Parse command line arguments */
template = 'SYSTEM/M,ALL/S,GLOBAL/S,USEEXCLUDES/S,PURGE/S,QUIET/S'
if arguments = '' then do
say 'Template: 'template
say 'Show the script in a text viewer for more information.'
exit(0)
end
address(bbsread)
'READARGS TEMPLATE 'template' STEM 'args' CMDLINE 'arguments
if rc ~= 0 then do
say BBSREAD.LASTERROR
say 'Template: 'template
say 'Show the script in a text viewer for more information.'
exit(0)
end
if (symbol('args.SYSTEM.COUNT') = 'VAR') & (args.ALL) then do
say 'You must specify either one or more system names or ALL.'
say 'Template: 'template
say 'Show the script in a text viewer for more information.'
exit(0)
end
if (args.ALL) then GETBBSLIST args.SYSTEM
FDF_DELETED = '00000001'x
totchecked = 0; dupes = 0;
do h = 1 to args.SYSTEM.COUNT
/* Initialize variables */
checked = 0; dupeshere = 0; adel = 0
address(bbsread)
'GETBBSDATA "'args.SYSTEM.h'" 'sysdata
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
if (right(sysdata.BBSPATH, 1) ~= ':') & (right(sysdata.BBSPATH, 1) ~= '/') then sysdata.BBSPATH = sysdata.BBSPATH || '/'
/*
** Read SortMail's exclude file
*/
if (args.USEEXCLUDES) & (exists(sysdata.BBSPATH || 'SortMail.excl')) then do
openexcl = open(ef, sysdata.BBSPATH || 'SortMail.excl', 'R')
if (openexcl) then do
cnt = 0
do until eof(ef)
entry = readln(ef)
if (entry ~= '') then do; cnt = cnt + 1; excldir.cnt = entry; end
end
excldir.count = cnt
call close(ef)
end
else say 'Could not open SortMail''s exclude file.'
end
/* Start the work... */
'GETFAREALIST BBSNAME "'args.SYSTEM.h'" STEM 'fareas
if (rc ~= 0) then do; say BBSREAD.LASTERROR; exit(0); end
if fareas.COUNT = 0 then do
say 'No file areas on this system.'
exit(0)
end
if ~args.QUIET then say '1B'x'[4mChecking for dupes on "'args.SYSTEM.h'" - 'fareas.COUNT' file areas.' || '1B'x'[0m' || '1B'x'[1B'
do i = 1 to fareas.COUNT
drop fadata.
'GETFAREADATA BBSNAME "'args.SYSTEM.h'" FAREANAME "'fareas.i'" STEM 'fadata
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
if ~args.QUIET then do
say '1B'x'[1A' || '1B'x'[K' || '1B'x'[1m'fareas.i || '1B'x'[0m'
say '1B'x'[1A' || '1B'x'[20Ccontains 'fadata.NUMFILES' files.'
say '1B'x'[1A' || '1B'x'[42C' || '1B'x'[3mProcessing...' || '1B'x'[0m' || '1B'x'[1B'
end
if (symbol('excldir.count') = 'VAR') then do j = 1 to excldir.count
if ((index(excldir.j, '/') > 0) & (fareas.i = excldir.j)) | (left(fareas.i, length(excldir.j)) = excldir.j) then do
if ~(args.QUIET) then say '1B'x'[2A' || '1B'x'[42C' || '1B'x'[3mDeleting...' || '1B'x'[0m' || '1B'x'[1B'
'CONFIGFAREA "'args.SYSTEM.h'" "'fareas.i'" DELETEFAREA'
if (rc ~= 0) then do; say BBSREAD.LASTERROR; exit(0); end
if ~(args.QUIET) then say '1B'x'[2A' || '1B'x'[42C' || '1B'x'[0mArea deleted.' || '1B'x'[0m' || '1B'x'[1B'
adel = adel + 1
iterate i
end
end
thisfile = fadata.FIRSTFILE
if fadata.NUMFILES > 0 then do until checked = fadata.NUMFILES
drop filetags. filedata. found.
'READBRFILE BBSNAME "'args.SYSTEM.h'" FAREANAME "'fareas.i'" FILENR 'thisfile' TAGSSTEM 'filetags' DATASTEM 'filedata
if (rc ~= 0) then do; say BBSREAD.LASTERROR; exit(0); end
nextfile = result
if (bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED) then do
'SEARCHBRFILE BBSNAME "'args.SYSTEM.h'" STEM 'found' SEARCH "'filetags.NAME'" NAME'
if (rc ~= 0) then do; say BBSREAD.LASTERROR; exit(0); end
do j = 1 to found.FILEAREA.COUNT
do k = 1 to found.FILE.j.COUNT
if (found.FILE.j.k ~= thisfile) then do
if ~(args.QUIET) then say '1B'x'[1A' || '1B'x'[KDupe: 'found.FILEAREA.j'/'filetags.NAME
'WRITEBRFILE BBSNAME "'args.SYSTEM.h'" FAREANAME "'found.FILEAREA.j'" UPDATEFILENR 'found.FILE.j.k' DELETEFILE'
if (rc ~= 0) then do; say BBSREAD.LASTERROR; exit(0); end
if ~(args.QUIET) then say '1B'x'[1A' || '1B'x'[42CDELETED'
dupes = dupes + 1; dupeshere = dupeshere + 1
end
end
end
checked = checked + 1; totchecked = totchecked + 1
thisfile = nextfile
end
end
if ~args.QUIET then say '1B'x'[2A' || '1B'x'[42C' || '1B'x'[K'dupeshere' dupes found.' || '1B'x'[1B'
checked = 0; dupeshere = 0
end
if args.PURGE & ~args.QUIET then 'PACKDATAFILE "'args.SYSTEM.h'" FILEDATA SHOWPROGRESS'
if args.PURGE & args.QUIET then 'PACKDATAFILE "'args.SYSTEM.h'" FILEDATA'
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
end
break_c:
halt:
if ~args.QUIET then say 'Checked 'totchecked' files and found 'dupes' duplicates. 'adel 'file areas were deleted.'